#include <iostream>

using namespace std;

// 基类
class Base
{
public:
    Base() {cout << "Base()" << endl;}
    virtual ~Base(){cout << "~Base()" << endl;}
};

class A : public Base
{
public:
    A() {cout << "A()" << endl;}
    virtual ~A(){cout << "~A()" << endl;}
};

class B : public Base
{
public:
    B() {cout << "B()" << endl;}
    virtual ~B(){cout << "~B()" << endl;}
};

int main()
{
    Base *a = new A;
    Base *b = new B;
    delete a;
    a = nullptr;
    delete b;
    b = nullptr;

    return 0;
}